
*******************************************************************************************
* Aarøe, Petersen & Arceneaux 2020
* replication dofile for the results from sample 6 DK 2013 nonelection sample
*******************************************************************************************

clear 
set more off

* use the following replication data set
"Replication dataset for the 2013 Danish sample 6.dta", replace

*******************************************************************************************
* Recodings
*******************************************************************************************

* Contamination disgust scale from the DS_R
recode q1_4 (1=1) (2=2) (3=3) (4=4)(5=5), gen (toilet04)
recode q1_9 (1=1) (2=2) (3=3) (4=4)(5=5), gen (cook09)
recode q2_5 (1=1) (2=2) (3=3) (4=4)(5=5), gen (soda18)
recode q2_9 (1=1) (2=2) (3=3) (4=4)(5=5), gen (chocl23)
recode q2_12 (1=1) (2=2) (3=3) (4=4)(5=5), gen (condom26)

egen contam_av = rmean (toilet04 cook09 soda18 chocl23 condom26)
ta contam_av
gen contam_av01 =contam_av/4
ta contam_av01

*scale reliability
alpha toilet04 cook09 soda18 chocl23 condom26


* vote preference (the political parties are coded according to how Danish voters placed them ideologically in the Danish election study)
recode q4 (7=8) (8=7) (3=6) (1=5) (5=4) (2=3) (4=2) (9=1) (else=.), gen (partinp) 
gen partinp01= (partinp-1)/7
ta partinp01


*party identification (the political parties are coded according to how Danish voters placed them ideologically in the Danish election study)
recode q5 (7=8) (8=7) (3=6) (1=5) (5=4) (2=3) (4=2) (9=1) (else=.), gen (partiidnp) 

gen partiidnp01= (partiidnp-1)/7
ta partiidnp01


* generating party identification and vote choice variables that do not include the Danish People's Party (for analyses of robustness)
recode partinp partiidnp (8=.), gen (partinpNODPP partiidnpNODPP)
gen partinpNODPP01 = (partinpNODPP-1)/6
gen partiidnpNODPP01 = (partiidnpNODPP-1)/6

*ideology
ta q3
gen ideo01=(q3-1)/6
ta ideo01

*Education
recode education (1=1) (2=3) (3=3) (4=2) (5=4) (6=5) (7=6) (8=7) (9=.) (else=.), gen (educ)
gen education01 =(educ-1)/6
ta education01

*gender
gen female=gender
recode female (1=1) (2=0)

*household income
gen houseincome1 =household_income
recode houseincome1 (1=1) (2=2) (3=3) (4=4) (5=5) (6=6) (7=7) (8=8) (9=9) (10=10) (11=11) (else=.)
ta houseincome1
gen houseincome01=(houseincome1-1)/10
ta houseincome01




*****************************************************************************
*analyses

****************************************************************************
* sample descriptives
sum female  
sum age  
ta educ 
ta household_income 


eststo clear
estpost tabstat contam_av01, statistics(mean sd N) columns(statistics)
esttab . , cells("mean sd N"), using part_2.rtf, replace
eststo clear

eststo clear
estpost tabstat partiidnp01 partinp01, statistics(mean sd N) columns(statistics)
esttab . , cells("mean sd N"), using part_2.rtf, replace
eststo clear

eststo clear
estpost tabstat ideo01, statistics(mean sd N) columns(statistics)
esttab . , cells("mean sd N"), using part_2.rtf, replace
eststo clear


* Average marginal effects for Figure 1 in the main text
*effect on party identification
quietly reg partiidnp01 contam_av01 female houseincome01 education01 age, level (90)
margins, dydx(contam_av01 houseincome01 education01) level (90) post 
est store pid
*effect of vote choice
quietly reg partinp01 contam_av01 female houseincome01 education01 age, level (90) 
margins, dydx(contam_av01 houseincome01 education01) level (90) post
est store vote
esttab pid vote, cell("b se"),  using "part_2.csv", replace


* Analyses for Table A12
eststo clear
eststo: reg partiidnp01 contam_av01 female houseincome01 education01 age, level (90)
eststo: reg partinp01 contam_av01 female houseincome01 education01 age, level (90)
eststo: reg partiidnpNODPP01 contam_av01 female houseincome01 education01 age, level (90)
eststo: reg partinpNODPP01 contam_av01 female houseincome01 education01 age, level (90)
eststo: ologit partiidnp01 contam_av01 female houseincome01 education01 age, level (90)
eststo: ologit partinp01 contam_av01 female houseincome01 education01 age, level (90)
esttab, b (%5.2f) se(%5.2f) , using part_3.rtf,replace onecell star(* 0.10 ** 0.02 *** 0.002) wide constant ar2
eststo clear

* calculating by hand the z-score for the difference between the coefficient for the effect of pathogen avoidance motivation on vote intentions in the models with and without the Danish People's Party
*  Vote choice: z-score =(0.2214137-0.1767384) /SQRT(0.0583561+0.0496582)
* z = 0.13593361. This corresponds to a one-sided p-value of 0.446, one-tailed) (calculated using https://www.socscistatistics.com/pvalues/normaldistribution.aspx) 

* Party indentification: z-score =(0.2528447-0.1769076 )/SQRT(0.0651973+0.0556033)
* z = 0.21848391. This corresponds to a one-sided p-value of 0.414, one-tailed) (calculated using https://www.socscistatistics.com/pvalues/normaldistribution.aspx) 


* analysis of robustness for Figure 2 reported in Online Appendix A3.2
reg partiidnp01 contam_av01 female houseincome01 education01 age, level (90)
gen miss=e(sample)

reg partiidnp01 female houseincome01 education01 age if miss==1, level (90)
margins, dydx (houseincome01 education01) level (90)

reg partinp01 contam_av01 female houseincome01 education01 age, level (90)
gen miss2=e(sample)
reg partinp01 female houseincome01 education01 age if miss2 ==1, level (90)
margins, dydx (houseincome01 education01) level (90)


*Analyses for Online Appendix A3.3. 
* the estimates were included in the dataset for the meta analysis for the effect of pathogen avoidance motivation on ideological preferences
* Average marginal effects for Figure A3
reg ideo01 contam_av01 female houseincome01 education01 age, level (90)
margins, dydx(contam_av01)
